<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Detailed features: GNOME Data Access 5 manual</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="index.html" title="GNOME Data Access 5 manual">
<link rel="up" href="gda-sql.html" title="Part VII. Gda SQL console's user manual">
<link rel="prev" href="ch41s02.html" title="Meta data">
<link rel="next" href="ch42s02.html" title="Internal parameters">
<meta name="generator" content="GTK-Doc V1.32 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts"></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="gda-sql.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="ch41s02.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="ch42s02.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="chapter">
<div class="titlepage"><div><div><h2 class="title">
<a name="gda-sql-manual-icommands"></a>Detailed features</h2></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="sect1"><a href="gda-sql-manual-icommands.html#id-1.8.7.3">Query buffer</a></span></dt>
<dt><span class="sect1"><a href="ch42s02.html">Internal parameters</a></span></dt>
<dt><span class="sect1"><a href="ch42s03.html">Embedded HTTP server</a></span></dt>
<dt><span class="sect1"><a href="ch42s04.html">Environment variables</a></span></dt>
</dl></div>
<p>
    This section explains in depth various aspects of the console tool.
  </p>
<div class="sect1">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="id-1.8.7.3"></a>Query buffer</h2></div></div></div>
<p>
      Everytime an SQL command is entered, it is stored in the query buffer associated to the current connection. 
      The query buffer can be edited using an external editor (which can be useful for multi line SQL statements) using
      the <span class="command"><strong>.e</strong></span> command. The query buffer can also be saved to a file and loaded back later using the
      <span class="command"><strong>.qw</strong></span> and <span class="command"><strong>.qr</strong></span> commands. To execute the SQL held in the current query buffer,
      use the <span class="command"><strong>.g</strong></span> command.
    </p>
<p>
      Query buffers can be saved to the dictionary (along with the connection's meta data) for future usage using the
      <span class="command"><strong>.qs buffer_name</strong></span> command, and loaded back later with the <span class="command"><strong>.ql buffer_name</strong></span>.
      To list all the saved query buffers in the dictionary, use the <span class="command"><strong>.qa</strong></span> command. The following example
      shows an example output of the <span class="command"><strong>.qa</strong></span> command where one query buffer has been saved:
      </p>
<pre class="programlisting">
SalesTest&gt; .qa
Query buffer name | SQL                                                                                   
------------------+---------------------------------------------------------------------------------------
orders_status     | select c.name, o.creation_date ,                                                      
                    (select count (product_ref) from order_contents oc where oc.order_id=o.id) as '#items'
                    from customers c                                                                      
                    	inner join orders o on (o.customer = c.id)                                           
                    order by o.creation_date;                                                             
                                                                                                          
(1 row)
SalesTest&gt;
      </pre>
<p>
    </p>
<p>
      The <span class="command"><strong>.g</strong></span> command can also be used to load a query buffer and execute its contents simply
      by passing the name of the query buffer to use as argument:
      </p>
<pre class="programlisting">
SalesTest&gt; .g orders_status
name           | creation_date | #items
---------------+---------------+-------
Lew Bonito     | 2003-06-28    |      1
Lew Bonito     | 2004-02-02    |      2
Mark Lawrencep | 2004-02-02    |      2
Mark Lawrencep | 2004-02-02    |      0
Greg Popoff    | 2004-02-02    |      1
Ed Lamton      | 2006-02-04    |      0
Ed Lamton      | 2006-02-05    |      0
Ed Lamton      | 2006-02-05    |      0
Ed Lamton      | 2006-03-29    |      0
(9 rows)
SalesTest&gt;
      </pre>
<p>
    </p>
</div>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.32</div>
</body>
</html>